package cn.edu.swu.io;

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        ImageManager imageManager = new ImageManager();
        Scanner scanner = new Scanner(System.in);
        int choice;

        do {
            //打印菜单
            System.out.println("\n=== 图片下载系统 ===");
            System.out.println("1. 下载图片");
            System.out.println("2. 查看所有图片");
            System.out.println("3. 搜索图片");
            System.out.println("4. 退出");
            System.out.println("==================");
            System.out.print("请输入选择：");
            choice = scanner.nextInt();
            scanner.nextLine();

            switch (choice) {
                case 1:
                    System.out.print("请输入图片URL：");
                    String url = scanner.nextLine();
                    imageManager.downloadImage(url);
                    break;
                case 2:
                    imageManager.listImages();
                    break;
                case 3:
                    System.out.print("请输入图片名：");
                    String name = scanner.nextLine();
                    imageManager.searchImage(name);
                    break;
                case 4:
                    System.out.println("欢迎下次使用！");
                    break;
                default:
                    System.out.println("输入无效，请重新选择！");
            }
        }while (choice != 4);
        scanner.close();
    }
}
